/*
 * Util.h
 *
 *  Created on: Sep 19, 2013
 *      Author: anand
 */

#include <stdlib.h>
#include <time.h>
#include <unistd.h>

#ifndef UTIL_H_
#define UTIL_H_

#define PAGE_SIZE 4096 // 4KB
#define ONE_KB 1024
#define ONE_MB 1048576 // 1 MB

double getDiffInNanoSeconds(struct timespec start, struct timespec end);
void validateAndFillInputArgument(int argc, char* argv[], long *n, char *argumentName);
void validateAndFillInputArguments(int argc, char* argv[], long *n1, char *argument1Name, long *n2, char *argument2Name);
void validateAndFill2InputArgumentsWithOption(int argc, char* argv[], long *n1,
		char *argument1Name, long *n2, char *argument2Name, int *option, char *optionName, int* n3, char* arg3Name);
void printStandardMemory();
char* getSizeInMB(long bytes);
char* getSizeInKB(long bytes);

char getRandomCharacter();
void fillAllocatedMemory(char *buffer, long bufferSize);

long getNextOffsetWithinPage(long offset, long increment, long bufferSize);
void swapCharacters(char *buffer, long firstOffset, long secondOffset);

#endif /* UTIL_H_ */
